package com.recsmile.rpc;

import com.recsmile.rpc.provider.MessageSendExecutor;
import com.recsmile.rpc.sample.Calculate;

import java.util.concurrent.CountDownLatch;

/**
 * Created by Administrator on 2016/8/11.
 */
public class CalcParallelRequestThread implements Runnable{
    private CountDownLatch signal;
    private CountDownLatch finish;
    private MessageSendExecutor executor;
    private int taskNumber;

    public CalcParallelRequestThread(CountDownLatch signal, CountDownLatch finish, MessageSendExecutor executor, int taskNumber) {
        this.signal = signal;
        this.finish = finish;
        this.executor = executor;
        this.taskNumber = taskNumber;
    }

    public void run() {
        try {
            signal.await();
            Calculate calculate = executor.newInstance(Calculate.class);
            System.out.println("calc add result:[" + calculate.add(taskNumber,taskNumber) + "]");
            finish.countDown();
        }catch (Exception e){
            e.printStackTrace();
        }finally {

        }
    }
}
